package com.linchong.springboot_jpa.controller;

import com.linchong.springboot_jpa.bean.User;
import com.linchong.springboot_jpa.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @BelongsProject:springboot_jpa
 * @BelongsPackage:com.linchong.springboot_jpa.controller
 * @Author:linchong
 * @CreateTime:2018-08-12 23:14
 * @Description:
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/save")
    public String save(){
       User user = new User();
       user.setName("张三");
       user.setId(3);
       user.setAge(18);
       userService.save(user);
       return "保存用户成功!";
    }

    @RequestMapping("/delete")
    public String delete(){

        userService.delete(001);
        return "删除用户成功！";
    }

    @RequestMapping("/getAll")
    public Iterable<User> getAll(){
        return userService.getAll();
    }



}
